home *** CD-ROM | disk | FTP | other *** search
- /*
- * This class manages the policies in use. This includes a client policy and
- * several server policies. Actual decisions are made by the policy objects
- * themselves.
- */
-
- var EXPORTED_SYMBOLS = [ ];
- Components.utils.import("resource://csfiremodules/CsFireCommon.jsm");
-
- CsFire.PolicyManager = new function() {
- this.enabled = true;
- }
-
- /*
- * This function delegates decision making for a certain request.
- * This decision will be dependent on the actual policy that will be used.
- */
- CsFire.PolicyManager.decide = function(data) {
- this._logDecisionData(data);
-
- var decision;
- if(this.enabled === true) {
- //Check if the request is whitelisted
- decision = CsFire.Whitelist.decide(data);
- if(decision == null) {
- //It is not, so check the server policy
- //TODO FUTURE Check server policy here (to be implemented)
- if(decision == null) {
- //No server policy, use autonomous client policy
- decision = CsFire.ClientPolicy.decide(data);
- }
- }
- }
- else {
- decision = { "action": CsFire.Policy.DISABLED };
- }
- CsFire.Logger.debug("Policy decision: " + CsFire.Policy.textualDecision(decision));
- return decision;
- }
-
- /*
- * Switches the "enabled" status of the policy
- */
- CsFire.PolicyManager.switchEnabledStatus = function() {
- this.enabled = !(this.enabled);
- CsFire.Logger.debug("Policy status changed (enabled: " + this.enabled + ")");
- }
-
- /*
- * Retrieves the enabled status of the policy
- */
- CsFire.PolicyManager.isEnabled = function() {
- return this.enabled;
- }
-
- /*
- * Logs the decision data to the error console for debugging
- */
- CsFire.PolicyManager._logDecisionData = function(data) {
- var dbg = "";
- for(var x in data) {
- dbg += (x + ": " + data[x] + " | ");
- }
- CsFire.Logger.debug("Decision data: " + dbg);
- }
-